<template>
  <div>
    <h2>登录页面</h2>
    <table border="1">
      <tr>
        <td>用户名：</td>
        <td><input type="text" v-model="s.UserName"/></td>
      </tr>

      <tr>
        <td>密码：</td>
        <td><input type="password" v-model="s.Pwd"/></td>
      </tr>

      <tr>
        <td></td>
        <td><input type="button" value="登录"  @click="login"/></td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
//定义一个路由对象
import {reactive,toRefs} from 'vue';
//跳转路由
import {useRouter} from 'vue-router';
const router=useRouter();
//获取路由对象
import axios from 'axios';
let data:any=reactive({
  s:{
    UserName:'',
    Pwd:''
  }
})
let {s} =toRefs(data);
let obj={
  userName: s.value.userName,
    pwd: s.value.pwd
}
console.log(obj);
const login=()=>{
  axios({
    url:'/api/Member/Dl',
    method:'get',
    params:s.value
  })
  .then((res)=>{
    if(res.data.data==null){
      alert('用户名不存在')
    }
    else{
      
      router.push('/add');
    }
  })
}










</script>

<style scoped>

</style>